// community.go
package form

import (
	"github.com/martini-contrib/binding"
	"martini_template/componnet"
	"net/http"
)

type PropertyForm struct {
	Id                    string `form:"id"`
	Name                  string `form:"name"`
	CommunityId           string `form:"community_id"`
	Description           string `form:"description"`
	CommunityBuildingId   string `form:"community_building_id"`
	Note                  string `form:"note"`
	ProprietorPhones      string `form:"proprietor_phones"`
	PropertyTotalFee      string `form:"property_total_fee"`
	PropertyPresentFee    string `form:"property_present_fee"`
	HouseType             string `form:"house_type"`
	Acreage               string `form:"acreage"`
	ProprietorName        string `form:"proprietor_name"`
	ProprietorPersonCount string `form:"proprietor_person_count"`
	Word                  string `form:"word"`
	Offset                int    `form:"offset"`
	Limit                 int    `form:"limit"`
	Sort                  string `form:"sort"`
	PropertyCompanyId     string `form:"property_company_id"`
	PayDay				  string `form:"pay_day"`
	Number                string `form:"number"`
	Address               string `form:"address"`
	Logo                  string `form:"logo"`
	RegisterTime          string `form:"register_time"`
	ContactPerson         string `form:"contact_person"`
	ContactPhone          string `form:"contact_phone"`
	HouseNumber           string `form:"house_number"`
	QrCode                string `form:"qr_code"`
	IsActive              string `form:"is_active"`
	Image                 string `form:"image"`
	MerchantId            string `form:"merchant_id"`
	HouseId				string `form:"house_id"`
	//user
	Username string `form:"username"`
	Nickname string `form:"nickname"`
	Password string `form:"password"`
	Sex      string `form:"sex"`
	Email    string `form:"email"`
	Avatar   string `form:"avatar"`
	//notice
	Title   string `form:"title"`
	Content string `form:"content"`
}

func (pf *PropertyForm) Validate(errors binding.Errors, req *http.Request) binding.Errors {
	if pf.Limit == 0 {
		pf.Limit = 10
	}
	pf.Id = componnet.FilterString(pf.Id)
	pf.Name = componnet.FilterString(pf.Name)
	pf.CommunityId = componnet.FilterString(pf.CommunityId)
	pf.Description = componnet.FilterString(pf.Description)
	pf.CommunityBuildingId = componnet.FilterString(pf.CommunityBuildingId)
	pf.Note = componnet.FilterString(pf.Note)
	pf.ProprietorPhones = componnet.FilterString(pf.ProprietorPhones)
	pf.PropertyTotalFee = componnet.FilterString(pf.PropertyTotalFee)
	pf.PropertyPresentFee = componnet.FilterString(pf.PropertyPresentFee)
	pf.HouseType = componnet.FilterString(pf.HouseType)
	pf.Acreage = componnet.FilterString(pf.Acreage)
	pf.ProprietorName = componnet.FilterString(pf.ProprietorName)
	pf.ProprietorPersonCount = componnet.FilterString(pf.ProprietorPersonCount)
	pf.Word = componnet.FilterString(pf.Word)
	pf.Sort = componnet.FilterString(pf.Sort)
	return errors
}
